package cn.kgm.nio;

import java.io.File;
import java.io.FileInputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class NioFilleChanalRead {
    private final static String nioUrl = "niofile/";

    public static void main(String[] args) throws Exception{
        File file = new File(nioUrl+"file.txt");
        FileInputStream fileInputStream = new FileInputStream(file);
        FileChannel channel = fileInputStream.getChannel();
        ByteBuffer allocate = ByteBuffer.allocate((int)file.length());
        channel.read(allocate);
        System.out.println(new String(allocate.array()));
    }
}
